﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SqliteGame : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        TestDb();
    }

    private void TestDb()
    {
        // /../ 意思是取上级目录
        string dbPath = Application.dataPath + "/../Save/SaveData.db";
        
        //SqlDbCommand sqldb = new SqlDbCommand(dbPath);
        SqlDbConnect sqldb = new SqlDbConnect(dbPath);
        //创建表
         // sqldb.CreateTable<CharacterSqliteData>();
         // SqlDbCommand.CreateTable<CharacterSqliteData>(sqldb);
        //删除表
        // sqldb.DeleteTable<CharacterData>();

        CharacterSqliteData c1 = new CharacterSqliteData()
        {
            Id=1121,
            Name="22a",
            Height = 1.68f,
            Sex = true
        }; 
        CharacterSqliteData c2 = new CharacterSqliteData()
        {
            Id=3,
            Name="33312你好b",
            Height = 2.01f,
            Sex = true
        };
        // List<CharacterData> list = new List<CharacterData>();
        // list.Add(c1);
        // list.Add(c2);
        //增加  插入数据
        // sqldb.Insert<CharacterData>(c);
         // sqldb.Insert<CharacterData>(list);
         // sqldb.Insert<CharacterData>(c1,c2);
         
         //删除表中的数据
         // sqldb.DeleteById<CharacterData>(23222);
         // sqldb.DeleteByIds<CharacterData>(1, 11);
        // sqldb.DeleteBySql<CharacterData>("Sex=1");
        // sqldb.UpdateById(c2);
        
        //查询数据
       // var  a=sqldb.SelectById<CharacterSqliteData>(3);
       // List<CharacterSqliteData> test = sqldb.SelectAll<CharacterSqliteData>();
       //判断表是否存在
       bool iscreated = sqldb.IsTableCreated<CharacterSqliteData>();
    }
    
}
